{
LANG : PASCAL
PROB : br2
}

program BR2;
const
  fi = 'br2.in';
  fo = 'br2.out';
  max = 1000;
  maxc = 2000000;
  oo = 1000000000;
var
  c, d : array[1..maxc] of longint;
  p : array[1..max] of longint;
  a, b, l, t : longint;

function prime(k : longint) : boolean;
var
  i, c : longint;
begin
  prime := false;
  c := trunc(sqrt(k));
  for i := 1 to l do
  begin
    if p[i] > c then break;
    if k mod p[i] = 0 then exit;
  end;
  prime := true;
end;

function bess(n : longint) : longint;
var
  i, m, temp : longint;
  res : longint;
begin
  m := n;
  res := 1;
  for i := 1 to l do
    if n mod p[i] = 0 then
    begin
      temp := p[i];
      while n mod p[i] = 0 do
      begin
        temp := temp*p[i];
        n := n div p[i];
      end;
      res := res * ((temp - 1) div (p[i] - 1));
    end;
  if n <> 1 then res := res*(n+1);
  dec(res, m);
  bess := res;
end;

procedure init;
var
  i : longint;
begin
  l := 0;
  for i := 2 to 1500 do
    if prime(i) then
    begin
      inc(l);
      p[l] := i;
    end;
  for i := 1 to maxc do d[i] := bess(i);
end;

procedure trace(k : longint);
var
  u : longint;
begin
  u := k;
  write(k, ' ');
  u := d[k];
  c[k] := -1;
  while u <> k do
  begin
    write(u, ' ');
    c[u] := -1;
    u := d[u];
  end;
  writeln;
end;

procedure process;
var
  i, time : longint;
begin
  for i := a to b do c[i] := i;
  for time := 1 to 50 do
  begin
    for i := a to b do
      if c[i] > 0 then
      begin
        if c[i] > maxc then c[i] := -1;
        c[i] := d[c[i]];
        if c[i] > maxc then c[i] := -1;
        if c[i] = i then
        begin
          trace(i);
        end;
      end;
  end;
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  read(a, b);
  init;
  process;
  close(output);
  close(input);
end.
